﻿namespace Tetris.Game.Common
{
    [AttributeUsage(AttributeTargets.Enum | AttributeTargets.Field)]
    public class DisplayTextAttribute : Attribute
    {
        public static readonly DisplayTextAttribute Default = new DisplayTextAttribute();

        public string DisplayText { get; private set; }

        public DisplayTextAttribute()
            : this(string.Empty)
        {
        }

        public DisplayTextAttribute(string text)
        {
            DisplayText = text;
        }

        public override bool Equals(object obj)
        {
            DisplayTextAttribute displayTextAttribute = obj as DisplayTextAttribute;
            if (displayTextAttribute != null)
            {
                return DisplayText.Equals(displayTextAttribute.DisplayText);
            }

            return false;
        }

        public override int GetHashCode()
        {
            return DisplayText.GetHashCode();
        }

        public override bool IsDefaultAttribute()
        {
            return Equals(Default);
        }
    }
}
